package com.huadao.cart_ccs.experiment.injection;

import com.huadao.cart_ccs.common.ProjectManager;
import com.huadao.cart_ccs.greendao.GreenDaoManager;
import com.huadao.cart_ccs.greendao.entity.Injection;
import com.huadao.cart_ccs.greendao.gen.InjectionDao;

import java.util.List;

public class InjectionPresenter extends InjectionContract.InjectionPresenter {

    private InjectionDao injectionDao;

    public InjectionPresenter(InjectionContract.IInjectionView baseView) {
        attachView(baseView);
        injectionDao= GreenDaoManager.getInstance().getNoCacheSession().getInjectionDao();
    }

    @Override
    void getHistoryInjection() {
        List<Injection> injectionList=injectionDao.queryBuilder().where(InjectionDao.Properties.ProjectId.eq(ProjectManager.getInstance().getProjectId())).list();
        baseView.onGetHistoryInjectionList(injectionList);
    }

    @Override
    public void saveInjection(Injection injection) {
        injectionDao.insert(injection);
    }
}
